package com.milotnt.enums;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;

@Schema(description = "器材状态枚举")
@Getter
public enum DeviceStatusEnum {

    @Schema(description = "正常")
    正常(1, "正常"),

    @Schema(description = "维修中")
    维修中(2, "维修中"),

    @Schema(description = "已报废")
    已报废(3, "已报废");

    private final Integer code;
    private final String description;

    DeviceStatusEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    public static String getDescriptionByCode(Integer code) {
        for (DeviceStatusEnum status : DeviceStatusEnum.values()) {
            if (status.getCode().equals(code)) {
                return status.getDescription();
            }
        }
        throw new RuntimeException("未找到对应枚举内容"); // 抛出异常
    }
}
